package indv.Cning.cfengsecuritydemo.config;

import org.springframework.context.annotation.Configuration;
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
import org.springframework.security.oauth2.config.annotation.configurers.ClientDetailsServiceConfigurer;
import org.springframework.security.oauth2.config.annotation.web.configuration.AuthorizationServerConfigurerAdapter;
import org.springframework.security.oauth2.config.annotation.web.configurers.AuthorizationServerSecurityConfigurer;

import javax.annotation.Resource;

/**
 * @author Cfeng
 * @date 2022/7/25
 * 认证服务模块的配置类,开启了认证服务就需要配置该类,不是安全配置
 */

@Configuration
public class AuthServerConfig {
//public class AuthServerConfig extends AuthorizationServerConfigurerAdapter {

//    @Resource
//    private BCryptPasswordEncoder passwordEncoder;
//
//    @Override
//    //权限管理配置
//    public void configure(AuthorizationServerSecurityConfigurer security) throws Exception {
//        security.tokenKeyAccess("permitAll()").checkTokenAccess("isAuthenticated()");
//    }
//
//    @Override
//    //使用Inmemory内存方式注册客户端,当然也可以是使用数据库模式JDBC
//    public void configure(ClientDetailsServiceConfigurer clients) throws Exception {
//        clients.inMemory()
//                .withClient("42660590")
//                .secret(passwordEncoder.encode("$2a$10$PHlIvvobgZFe2E3opVF4aOc8MMXqdxFMwEJXod90A1HjqHS/ECaW."))
//                //授权模式为授权码
//                .authorizedGrantTypes("authorization_code")
//                .scopes("user_info")
//                .autoApprove(true)
//                //注册重定向Uri
//                .redirectUris("http://localhost:8082/ui/login","http://localhost:8083/ui2/login");
//    }
}
